<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>评价司机</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/customer.js"></script>
</head>
<body>
<div id="orderOk" class="mb56">

</div>
<section class="bottomarea">
    <button class="btn bottomonebtn" onclick="save()">提交</button>
</section>
<input type="hidden" id="score" name="score" value="0" />
<input type="hidden" id="waybillId" name="waybillId"/>

</body>
<script>
$(function (){
	 //token验证
		checkToken();
	}); 
$(function (){
	 var LocString = String(window.document.location.href); 
		var waybillId=GetArgsFromHref("waybillId");  
		 var url = _global.serverHost +"/consignerOrderManger/orderEvaluation.htm";
		//'customerUuid':customerUuid
			var customerUuid=getCookie("customerUuid")
	     var data = {
	    		 'waybillId':waybillId,
	    		 'customerUuid':customerUuid
	     };
	     _callAjaxRequest(url, data, callBack);

	     function callBack(data) {
	    	 var orderOkhtml='';
	    	 
	    	 var payList=data.payList;
	    	 var allAmount=0;
	    	 var payTypeName='微信';
	    	 if(payList!=null && payList.length>0){
	    		 payTypeName=payList[0].payTypeName;
	    		 for(var i=0;i<payList.length;i++){
	    			 allAmount=allAmount*1+ payList[0].totalAmount*1;
	    		 }
	    	 }
	    	 orderOkhtml=orderOkhtml+'<form id="orderEvaluation" name="orderEvaluation">';
	    	 //orderOkhtml=orderOkhtml+' <button type="button" onclick="save()">提交</button>';
	    	 orderOkhtml=orderOkhtml+'<form id="orderEvaluation" name="orderEvaluation">'
	    		+'<section class="bigicon">'
	    		+'<i class="iconfont">&#xe613;</i>'
	    		+'</section>';
	    		orderOkhtml=orderOkhtml+'<section class="submit_ok_text">'
	    		+'<span class="oktext">付款成功</span> <span class="icon20 mt10 p5b">实际付款<label class="red">'
	    		+allAmount
	    		+'</label>元';
	    		orderOkhtml=orderOkhtml+'</span> <span class="font14 p5t p5b"><label class="gray mr5">支付方式:</label>'
	    		+payTypeName
	    		+'</span>'
	    		+'</section>';
	    		orderOkhtml=orderOkhtml+'<section class="itemgroup mt20">'
	    		+'<div class="evaluatetitle">评价司机</div>'
	    		+'<div class="star_item" id="star">'
	    		+'<i class="iconfont star_xl">&#xe640;</i> <i class="iconfont star_xl">&#xe640;</i>'
	    		+'<i class="iconfont star_xl">&#xe640;</i> <i class="iconfont star_xl">&#xe640;</i>'
	    		+'<i class="iconfont star_xl">&#xe640;</i>'
	    		+'</div>';
	    		orderOkhtml=orderOkhtml+'<div class="photoitem p15">';
	    					var index=0;
	    					
	    					var assessDriverList=data.assessDriverList;
	    					if(assessDriverList!=null &&assessDriverList.length>0){
	    						
	    						for(var i=0;i<assessDriverList.length;i++){
	    							orderOkhtml=orderOkhtml+'<input type="hidden" id="assessFlag'+assessDriverList[i].id +'" name="assessFlag"'
	    							+'	value="0" />';
	    							orderOkhtml=orderOkhtml+'<input type="hidden" id="indexCode'+assessDriverList[i].id+'" name="indexCode"'
	    							+'value="'+assessDriverList[i].codeValue+'" />'
		    								+'<input type="hidden" id="indexDesc$'+assessDriverList[i].id +'" name="indexDesc"'
		    								+'value="'+assessDriverList[i].cvName +'" />';
		    								index++;
		    								
		    								if(index%2==0){
		    									orderOkhtml=orderOkhtml+'<button type="button" id="button'+assessDriverList[i].id+'"'
		    									+'class="btnkuang_bl evaluatebtn" onclick="assessInfo('+assessDriverList[i].id+')">'+assessDriverList[i].cvName+'</button>';
		    								}else{
		    									orderOkhtml=orderOkhtml+'<button type="button" id="button'+assessDriverList[i].id+'"'
		    									+'class="btnkuang_bl evaluatebtn mr4p" onclick="assessInfo('+assessDriverList[i].id+')">'+assessDriverList[i].cvName +'</button>';
		    								}
		    					}
	    					}
	    					
	    					orderOkhtml=orderOkhtml+'</div>'
	    					+'</section>';
	    					orderOkhtml=orderOkhtml+'<input type="hidden" id="score" name="score" value="0" /> ';
	    					orderOkhtml=orderOkhtml+'<input type="hidden" id="waybillId" name="waybillId"'
	    					+'value="'+waybillId+'" />'
	    					orderOkhtml=orderOkhtml+'<input type="hidden" id="customerUuid" name="customerUuid" />';
	    					+'</form>';
	    					
	    	 $("#orderOk").html(orderOkhtml);
	    	 
	     }
	
});

 $( function(){
	
	  var star = document.getElementById("star");
	    var star_li = star.getElementsByTagName("i");
	    var i=0;
	    var j=0;
	    var len = star_li.length;
	    
	    for(i=0; i<len; i++){
	      star_li[i].index = i;
	        
	        star_li[i].onmouseover = function(){

	                for(i=0; i<=this.index; i++){
	                  star_li[i].className = "iconfont star_xl_foucs";
	                }
	                for(j=this.index+1; j<=5; j++){
	                    star_li[j].className = "iconfont star_xl";
	                   }
	        }

	    
	        star_li[i].onclick = function(){
	          $("#score").val(this.index+1);
	        }
	    }

	}); 
	
 function save() {
	//'customerUuid':customerUuid
		var customerUuid=getCookie("customerUuid")
		$("#customerUuid").val(customerUuid);
    $.ajax({
        type:'POST',
        url: _global.serverHost +'/consignerOrder/saveAssess.htm',
        data: $('#orderEvaluation').serialize(),
        contentType:"application/x-www-form-urlencoded;charset=UTF-8",
        success: function (data) {
        	alert(data.outResultReason);
        	if(data.outResult=='1'){
        		//window.location.href="${pageContext.request.contextPath}/consignerRegisterAndLogin/loginSuccess.htm?";
        		window.location.href="../../customer/index.html";
        	}
        }
    });
}
function assessInfo(id){
	var assessFlag=$("#assessFlag"+id).val();
	//未选中，点击变为选中
	if(assessFlag=='0'){
		$("#assessFlag"+id).val("1");
		$("#button"+id).removeClass('btnkuang_bl evaluatebtn');
		$("#button"+id).addClass('btn evaluatebtn');
	}else{
		$("#assessFlag"+id).val("0");
		$("#button"+id).removeClass('btn evaluatebtn');
		$("#button"+id).addClass('btnkuang_bl evaluatebtn');
	}
}
 

</script>
</html>
